package cn.px.service.maintain.impl;

import com.github.pagehelper.PageHelper;
import cn.px.common.bean.AbstractPageResultBean;
import cn.px.dao.bean.MyPage;
import cn.px.dao.dto.maintain.MaintainStandardParamDTO;
import cn.px.dao.entity.maintain.MaintainStandardParam;
import cn.px.dao.mapper.maintain.MaintainStandardParamMapper;
import cn.px.service.base.impl.BaseServiceImpl;
import cn.px.service.maintain.MaintainStandardParamService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.weekend.Weekend;
import tk.mybatis.mapper.weekend.WeekendCriteria;

import java.util.List;

/**
 * @Description 保养润滑标准参数 service 实现类
 * @author 品讯科技
 * @date 2024-08
 * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
 */
@AllArgsConstructor
@Service("maintainStandardParamService")
public class MaintainStandardParamServiceImpl extends BaseServiceImpl<MaintainStandardParamMapper, MaintainStandardParam, MaintainStandardParamDTO> implements MaintainStandardParamService {

    @Override
    public int batchDelete(List<String> ids) {
        Weekend<MaintainStandardParam> weekend = new Weekend<>(MaintainStandardParam.class);
        WeekendCriteria<MaintainStandardParam, Object> weekendCriteria = weekend.weekendCriteria();
        weekendCriteria.andIn(MaintainStandardParam::getId, ids);
        mapper.deleteByExample(weekend);
        return 1;
    }

    @Override
    public AbstractPageResultBean<MaintainStandardParam> selectPageInfo(MaintainStandardParamDTO record, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        AbstractPageResultBean<MaintainStandardParam> pageInfo = new MyPage(mapper.selectList(record));
        return pageInfo;
    }
}
